package com.travel.controller.admin;

import com.travel.model.dto.common.ApiResponse;
import com.travel.model.dto.destination.DestinationDTO;
import com.travel.service.Service.DestinationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
//管理员景点管理接口 , 创建, 更新, 删除景点, 查询景点列表, 查询景点详细信息, 
@Tag(name = "管理员景点", description = "管理员景点管理接口")
@RestController
@RequestMapping("/api/admin/destinations")
@RequiredArgsConstructor
@PreAuthorize("hasRole('ADMIN')")
public class AdminDestinationController {
    
    private final DestinationService destinationService;
    
    @Operation(summary = "创建景点")
    @PostMapping
    public ApiResponse<DestinationDTO> createDestination(@Valid @RequestBody DestinationDTO destinationDTO) {
        return ApiResponse.success("创建成功", destinationService.createDestination(destinationDTO));
    }
    
    @Operation(summary = "更新景点")
    @PutMapping("/{id}")
    public ApiResponse<DestinationDTO> updateDestination(
            @PathVariable Long id,
            @Valid @RequestBody DestinationDTO destinationDTO) {
        return ApiResponse.success("更新成功", destinationService.updateDestination(id, destinationDTO));
    }
    
    @Operation(summary = "删除景点")
    @DeleteMapping("/{id}")
    public ApiResponse<Void> deleteDestination(@PathVariable Long id) {
        destinationService.deleteDestination(id);
        return ApiResponse.success("删除成功");
    }
} 